package total;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

61
public class Ques1892 {
	
	public void go(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int k = scan.nextInt();
			Rule[] ruleArr = new Rule[n];
			Queue<Integer> q = new LinkedList();
			for (int i = 0; i < n; i++) {
				Rule rule = new Rule();
				rule.left = scan.nextInt();
				rule.right = scan.nextInt();
				ruleArr[i] = rule;
			}
			Arrays.sort(ruleArr);
			int ans = 0;
			for (int i = 0; i < n; i++) {
				if(q.size() < k){
					q.add(ruleArr[i].right);
					if(q.size() == k)ans = Math.max(ans, q.peek() - ruleArr[i].left + 1);
				}else{
					if(ruleArr[i].right > q.peek()){
						q.poll();
						q.add(ruleArr[i].right);
					}
					ans = Math.max(ans, q.peek() - ruleArr[i].left + 1);
				}
			}
			System.out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Ques1892().go();
	}
	
	class Rule implements Comparable<Rule>{
		int left,right;

		@Override
		public int compareTo(Rule o) {
			// TODO Auto-generated method stub
			return left - o.left;
		}
	}
}
